import categoryApi from "@/api/category"

export default {
    namespaced: true,
    state:{
        c1List:[],
        c2List:[],
        c3List:[],
    },
    mutations:{
        savec1List(state,params){
            state.c1List=params
        },
        savec2List(state,params){
            state.c2List=params
        },
        savec3List(state,params){
            state.c3List=params
        },
        //清空数据
        reset2List(state){
            state.c2List = [],
            state.c3List = []
        },
        reset3List(state){
            state.c3List = []
        }
    },
    actions:{
        async getCategory1List({commit},params){
            let res = await categoryApi.getCategory1()
            commit("savec1List",res.data)
            commit('reset2List')
        },
        async getCategory2List({commit},params){
            let res = await categoryApi.getCategory2(params)
            commit("savec2List",res.data)
            commit('reset3List')
        },
        async getCategory3List({commit},params){
            let res = await categoryApi.getCategory3(params)
            commit("savec3List",res.data)
        }
    }
}